import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

// https://vitejs.dev/config/
export default defineConfig({
  // 公共基础路径
  base: './', 
  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
    },
  },
  //改变css样式
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use '@/assets/scss/element.scss' as *;`,
      },
    },
  },
  plugins: [
    vue(),
    //使用element插件
    AutoImport({
      resolvers: [
        ElementPlusResolver({
          importStyle: "sass",
        }),
      ],
    }),
    Components({
      resolvers: [
        ElementPlusResolver({
          importStyle: "sass",
        }),
      ],
    }),
  ],
  build: {
    rollupOptions: {
      external: []
    }
  },
  //启动配制
  server: {
    host: "0.0.0.0",
    port: "8585", // 指定开发服务器端口
    cors: true, //配制cors
    //配置自定义代理规则
    proxy: {
      "/api": {
        target: 'http://127.0.0.1:3000/',
        // target: config.VITE_BASIC_API,
        changeOrigin: true,
      },
    },
  },
});
